import { Component, Input } from '@angular/core';
import { CustomerContact } from 'src/app/@core/data/customer';
import { SupplyContact } from 'src/app/@core/data/supplier';

@Component({
  selector: 'app-add-link-man',
  templateUrl: './add-link-man.component.html',
  styleUrls: ['./add-link-man.component.scss']
})
export class AddLinkManComponent {
  @Input() data: any
  form: CustomerContact = {
    customerContactId:null,
    customerCustomerContactId:null,
    customerContactName: '',
    gender: true,
    birthday: null,
    phone: '',
    email: '',
    address: '',
    fax: '',
    qq: '',
    weChat: '',
    isDefault: false,
  }
  supplierLinkMan:SupplyContact = {
    supplyContactId: null,
    supplyContactName: '',
    sex: '男',
    birthday: null,
    phone: '',
    address: '',
    email: '',
    qq: '',
    weChat: '',
    contactSupplyId: null,
    isDefault: false
  }
  genderOption = [
    {
      name: '男',
      value: true
    },
    {
      name: '女',
      value: false
    },
  ]
  sexOption = [
    "男","女"
  ]
  pathPids: any = []
  constructor() { }
  ngOnInit(): void {
    if(this.data.name == '供应商'){
      if(this.data.rowItem){
        this.supplierLinkMan.supplyContactId = this.data.rowItem.supplyContactId
        this.supplierLinkMan.supplyContactName = this.data.rowItem.supplyContactName
        this.supplierLinkMan.contactSupplyId = this.data.rowItem.contactSupplyId
        this.supplierLinkMan.address = this.data.rowItem.address
        this.supplierLinkMan.birthday = new Date(this.data.rowItem.birthday)
        this.supplierLinkMan.email = this.data.rowItem.email
        this.supplierLinkMan.isDefault = this.data.rowItem.isDefault
        this.supplierLinkMan.phone = this.data.rowItem.phone
        this.supplierLinkMan.qq = this.data.rowItem.qq
        this.supplierLinkMan.weChat = this.data.rowItem.weChat
        this.supplierLinkMan.sex = this.data.rowItem.sex
      }
    }else{
      if (this.data.rowItem) {
        this.form.birthday = new Date(this.data.rowItem.birthday)
        this.form.customerContactId = this.data.rowItem.customerContactId
        this.form.address = this.data.rowItem.address
        this.form.customerCustomerContactId = this.data.rowItem.customerCustomerContactId
        this.form.customerContactName = this.data.rowItem.customerContactName
        this.form.email = this.data.rowItem.email
        this.form.fax = this.data.rowItem.fax
        this.form.gender = this.data.rowItem.gender
        this.form.isDefault = this.data.rowItem.isDefault
        this.form.phone = this.data.rowItem.phone
        this.form.qq = this.data.rowItem.qq
        this.form.weChat = this.data.rowItem.weChat
      }
    }
  }
  ngModelChange() {
  }
}
